#include <iostream>
#include <vector>

int removeElement(std::vector<int>& nums, int val) {
    int i = 0;
    for (int j = 0; j < nums.size(); j++) {
        if (nums[j] != val) {
            nums[i] = nums[j];
            i++;
        }
    }
    return i;
}

int main() {
    std::vector<int> nums = {3, 2, 2, 3};
    int val = 3;
    
    int length = removeElement(nums, val);
    
    std::cout << "New length of the array: " << length << std::endl;
    std::cout << "Updated array: ";
    for (int i = 0; i < length; i++) {
        std::cout << nums[i] << " ";
    }
    
    return 0;
}
